package 程序员面试金典;

import org.junit.Test;

import java.util.concurrent.ScheduledExecutorService;

public class 判定是否是为字符重排 {

    public boolean CheckPermutation(String s1, String s2) {
       if (s1.length()!=s2.length())
           return false;
       int sum=0;
        boolean[] booleans = new boolean[s1.length()];
        for (int i = 0; i < s1.length(); i++) {
            for (int j = 0; j < s2.length(); j++) {
                if (s1.charAt(i)==s2.charAt(j) && booleans[j]==false){
                    booleans[j]=true;
                    sum++;
                    break;
                }
            }
        }
        return sum==s1.length();
    }
    @Test
    public void test(){
        System.out.println(CheckPermutation("aab", "abb"));
    }
}
